<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer">
      <span class="todo-count"><strong>{{count}}</strong>剩余</span>
      <ul class="filters">
        <li>
          <a :class="{selected:type=='all'}" href="#/" @click="filterType('all')">全部</a>
        </li>
        <li>
          <a :class="{selected:type=='active'}" href="#/active" @click="filterType('active')">进行中</a>
        </li>
        <li>
          <a :class="{selected:type=='completed'}" href="#/completed" @click="filterType('completed')">已完成</a>
        </li>
      </ul>
      <button @click="clearDone" v-show="clearIsDone" class="clear-completed">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  props:{
    list:{
      type:Array,
      required:true,
    },
    type:{
      type:String,
    },
  },
  data () {
    return {
    }
  },
  computed:{
    count(){
      return this.list.filter(item=>item.isDone === false).length
    },
    clearIsDone(){
      return this.list.some(item=>item.isDone)
    }
  },
  created () {

  },

  methods: {
    // 清除已完成
    clearDone(){
      this.$emit('cleardone')
    },
    // 高亮
    filterType(type){
      this.$emit('filterType',type)
    }
  }
}
</script>

<style scoped lang='scss'>

</style>
